<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<link rel="stylesheet" href="${ctx}/css/sapar.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/css/common.css" />
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/js/sapar.js"></script>
<script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
<script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
<script type="text/javascript" src="${ctx}/js/mask.js"></script>
<title>编辑财产</title>
<style>
#mc{
width:100px;
}
</style>
</head>

<body>
<div id="mask" class="mask"></div>
    <div id="saper-container">
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>编辑财产</h2>
            </div>
			<div class="subfiled-content">
	            <form class="saper-form" id="dataForm">
	            	<div class="kv-item clearfix">
	                    <label id="mc"><span class="impInfo">*</span>科室名：</label>
	                    <div class="kv-item-content">
	                        <input type="text" placeholder="科室名" class="txt_required" name="departmentName" id="departmentName" value="${kucun.department.departmentName}" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')" readonly="readonly">
	                        <input type="hidden"  class="txt_required" name="keshiId" value="${kucun.keshiId}">
	                    </div>
	                </div>
	                <div class="kv-item clearfix">
	                    <label id="mc"><span class="impInfo">*</span>产品名：</label>
	                    <div class="kv-item-content">
	                        <c:if test="${kucun.kucunSort == 1 }">
	                            <input type="text" placeholder="产品名" class="txt_required" name="packageName" id="packageName" value="${kucun.packageMuban.packageName}" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')" readonly="readonly">
	                            <input type="hidden"  class="txt_required" name="mubanId" value="${kucun.mubanId}">
	                            <input type="hidden"  class="txt_required" name="kucunSort" value="1">
	                        </c:if>
	                        <c:if test="${kucun.kucunSort == 2 }">
	                            <input type="text" placeholder=产品名" class="txt_required" name="packageName" id="packageName" value="${kucun.yicipinKucun.productName}" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')" readonly="readonly">
	                            <input type="hidden"  class="txt_required" name="mubanId" value="${kucun.mubanId}">
	                            <input type="hidden"  class="txt_required" name="kucunSort" value="2">
	                        </c:if>
	                    </div>
	                </div>
	                <%-- <div class="kv-item clearfix">
	                    <label id="mc"><span class="impInfo">*</span>已有库存 ：</label>
	                    <div class="kv-item-content">
	                        <input type="text" placeholder="已有库存 " class="txt_required" name="yiyouKucun" id="yiyouKucun" value="${kucun.yiyouKucun}" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
	                    </div>
	                </div> --%>
	                <input type="hidden" class="txt_required" name="yiyouKucun" value="${kucun.yiyouKucun}">
					<%-- <div class="kv-item clearfix">
	                    <label id="mc"><span class="impInfo">*</span>新增库存 ：</label>
	                    <div class="kv-item-content">
	                        <input type="text" placeholder="新增库存 " class="txt_required" name="xinzengKucun" onkeyup="this.value=this.value.replace(/\D/g,'')">
	                        <input type="hidden" class="txt_required" name="yixinzeng" value="${kucun.xinzengKucun }">
	                    </div>
	                </div> --%>
	                <div class="kv-item clearfix">
	                    <label id="mc">丢失库存 ：</label>
	                    <div class="kv-item-content">
	                        <input type="text" placeholder="丢失库存"  name="diushiKucun" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
	                        <input type="hidden" name="yidiushi" value="${kucun.diushiKucun }">
	                    </div>
	                </div>
	                <div class="buttons">
	                    <a href="javascript:;" class="sapar-btn sapar-btn-recom">确定</a>
	                    <input type="hidden" name="kucunId" id="kucunId" value="${kucun.kucunId}"/>
	                </div>
	            </form>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript">
function isNullOrEmpty(strVal){
	strVal = strVal.replace(/(^\s*)|(\s*$)/g,"");
	if(strVal == '' || strVal == null || strVal == undefined){
		return true;
	}else{
		return false;
	}
}

$(function(){
	$(".sapar-btn-recom").click(function(){
		 var btn = true;
		 $(".txt_required").each(function(){
			 var str =$(this).val();
			//var str = $(this).replace(/(^\s*)|(\s*$)/g,"");
			 if(isNullOrEmpty(str)){
				 btn = false;
				 layer.msg("必填项不为空");
				 return false;
			 }
		 });
		 if(btn){
			 showMask();
			 $.ajax({
	             type: "POST",
	             url:"${ctx}/keshikucun/kucunEdit.do",
	             data:$('#dataForm').serialize(),// 你的formid
	             error: function(request) {
	            	 	layer.alert("网络故障，请稍后再试!");
	             },
	             success: function(data) {
	            	 $("#mask").hide();
	 	           	if(data.status=="true"){
		 	           	layer.alert("保存成功", function(){
		 	           		window.location.href="${ctx}/keshikucun/keshikucunList.do";
	           		    });
	 	           	}else{
	 	           		 layer.msg(data.msg);
	 	           	}
	             }
	         }); 
		 }
	});
	
	/* $('#manufactorName').change(function(){
		var manufactorName = $('#manufactorName').val();
//		速记码生成器
		$.ajax({
			url:"${ctx}/eng/cn2en.do?msg="+manufactorName,
			dateType:"json",	
			success:function(data){
				if(data.status == "true"){
					 $("#manufactorCode").val(data.msg);
				}
			}
		});
	}); */
});
</script>
</html>